package capricornus.components.button
{
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	
	/**
	 * 皮肤容器；不用管 
	 * @author kael
	 * 
	 */	
	internal class BtnSkin extends Sprite
	{
		private var _w:int = -1;
		private var _h:int = -1;
		
		public function BtnSkin()
		{
			super();
		}
		
		public function setSize( w:int, h:int ):void
		{
			_w = w;
			_h = h;
			refresh();
		}
		
		public function resetSin( skin:DisplayObject ):void
		{
			while( numChildren > 0 ) removeChildAt(0);
			addChild( skin );
		}
		
		private function refresh():void
		{
			if( numChildren > 0 )
			{
				var dis:DisplayObject = getChildAt(0);
				if( _w != -1 ) dis.width = _w;
				if( _h != -1 ) dis.height = _h;
			}
		}
		
		override public function addChild(child:DisplayObject):DisplayObject
		{
			var ret:DisplayObject = super.addChild( child );
			refresh();
			return ret;
		}
	}
}